﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace RayTracer
{
    /// <summary>
    /// Erweitert .NET-Klassen um Raytracerspezifische Methoden.
    /// </summary>
    public static class NetExtension
    {
        #region Graphics
        /// <summary>
        /// Schreibt einen Text mit Hintergrund in Courier New 10pt.
        /// </summary>
        /// <param name="g">Das Grafikelement.</param>
        /// <param name="position">Die Position des Textes.</param>
        /// <param name="text">Der Text.</param>
        /// <param name="foreground">Die Textfarbe.</param>
        /// <param name="background">Die Hintergrundfarbe.</param>
        public static void WriteHUDText(this Graphics g, PointF position, string text, Color foreground, Color background)
        {
            g.FillRectangle(new SolidBrush(Color.FromArgb(background.A / 4, background.R, background.G, background.B)), new Rectangle((int)position.X - 2, (int)position.Y - 2, (int)(text.Length * 9f) + 2, 18 + 2));
            g.FillRectangle(new SolidBrush(Color.FromArgb((int)(background.A / 3f), background.R, background.G, background.B)), new Rectangle((int)position.X - 1, (int)position.Y - 1, (int)(text.Length * 9f) - 1, 18 - 1));
            g.FillRectangle(new SolidBrush(Color.FromArgb(background.A / 2, background.R, background.G, background.B)), new Rectangle((int)position.X, (int)position.Y, (int)(text.Length * 9f), 18));
            g.DrawString(text, new Font("Courier New", 10, FontStyle.Bold), (new Pen(foreground)).Brush, position);
        }
        #endregion Graphics
    }
}
